{extend name="base"/}
{block name="resources"}
<link rel="stylesheet" href="ADMIN_CSS/index.css">
{/block}
{block name="main"}
{if $sync_status == 1}
<p class="version-upgrade ns-border-color">
	温馨提示：检测到证书可更新，请到
	<a href="{:url('admin/upgrade/auth')}" target="_blank" class="ns-text-color">系统授权</a> 页面中点击更新证书
	<span>x</span>
</p>
{/if}
<div class="index-box">
	<div class="index-content">
		<div class="basic-info">
			<blockquote class="layui-elem-quote">基础信息 <span class="ns-card-sub"></span></blockquote>
            <div class="admin-row">
                <div class="admin-col-md2">
                    <div class="ns-survey-detail-con">
                        <div class="overview-box">
                            <div class="overview-title">
                                <div class="overview-title-text">今日新增用户</div>

                                <div class="title ns-prompt-block overview-prompt">
                                    <div class="ns-prompt">
                                        <button class="layui-btn layui-btn-primary ns-text-color ns-border-color ns-survey-yesterday-btn">昨日</button>
                                        <div class="ns-prompt-box">
                                            <div class="ns-prompt-con">
                                                昨日新增用户数：{$yesterday_data.user_count}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="clear"></div>
                            </div>

                            <div class="overview-value">{$today_data.user_count}</div>
                            <div class="overview-rate">
                                <div>日同比 {$ratio_data.user_count}
                                    {if $ratio_data.user_count > 0}
                                    <img src="SHOP_IMG/shop-rate-add.png">
                                    {else /}
                                    <img src="SHOP_IMG/shop-rate-less.png">
                                    {/if}
                                </div>
                                <div>昨日用户新增 {$yesterday_data.user_count}</div>
                            </div>

                            <div class="overview-bottom">
                                <div class="overview-bottom-text">用户总数</div>
                                <div class="overview-bottom-value">{$total_data.user_count}</div>
                                <div class="clear"></div>
                            </div>
                        </div>

                    </div>
                </div>

                <div class="admin-col-md2">
                    <div class="ns-survey-detail-con">
                        <div class="overview-box">
                            <div class="overview-title">
                                <div class="overview-title-text">今日新增店铺数</div>

                                <div class="title ns-prompt-block overview-prompt">
                                    <div class="ns-prompt">
                                        <button class="layui-btn layui-btn-primary ns-text-color ns-border-color ns-survey-yesterday-btn">昨日</button>
                                        <div class="ns-prompt-box">
                                            <div class="ns-prompt-con">
                                                昨日新增店铺数：{$yesterday_data.site_count}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="clear"></div>
                            </div>

                            <div class="overview-value">{$today_data.site_count}</div>
                            <div class="overview-rate">
                                <div>日同比 {$ratio_data.site_count}
                                    {if $ratio_data.site_count > 0}
                                    <img src="SHOP_IMG/shop-rate-add.png">
                                    {else /}
                                    <img src="SHOP_IMG/shop-rate-less.png">
                                    {/if}
                                </div>
                                <div>昨日店铺新增 {$yesterday_data.site_count}</div>
                            </div>

                            <div class="overview-bottom">
                                <div class="overview-bottom-text">店铺总数</div>
                                <div class="overview-bottom-value">{$total_data.site_count}</div>
                                <div class="clear"></div>
                            </div>
                        </div>

                    </div>
                </div>

                <div class="admin-col-md2">
                    <div class="ns-survey-detail-con">
                        <div class="overview-box">
                            <div class="overview-title">
                                <div class="overview-title-text">今日新增订单数</div>

                                <div class="title ns-prompt-block overview-prompt">
                                    <div class="ns-prompt">
                                        <button class="layui-btn layui-btn-primary ns-text-color ns-border-color ns-survey-yesterday-btn">昨日</button>
                                        <div class="ns-prompt-box">
                                            <div class="ns-prompt-con">
                                                昨日新增订单数：{$yesterday_data.order_count}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="clear"></div>
                            </div>

                            <div class="overview-value">{$today_data.order_count}</div>
                            <div class="overview-rate">
                                <div>日同比 {$ratio_data.order_count}
                                    {if $ratio_data.order_count > 0}
                                    <img src="SHOP_IMG/shop-rate-add.png">
                                    {else /}
                                    <img src="SHOP_IMG/shop-rate-less.png">
                                    {/if}
                                </div>
                                <div>昨日订单新增 {$yesterday_data.order_count}</div>
                            </div>

                            <div class="overview-bottom">
                                <div class="overview-bottom-text">订单总数</div>
                                <div class="overview-bottom-value">{$total_data.order_count}</div>
                                <div class="clear"></div>
                            </div>
                        </div>

                    </div>
                </div>

                <div class="admin-col-md2">
                    <div class="ns-survey-detail-con">
                        <div class="overview-box">
                            <div class="overview-title">
                                <div class="overview-title-text">今日收入</div>

                                <div class="title ns-prompt-block overview-prompt">
                                    <div class="ns-prompt">
                                        <button class="layui-btn layui-btn-primary ns-text-color ns-border-color ns-survey-yesterday-btn">昨日</button>
                                        <div class="ns-prompt-box">
                                            <div class="ns-prompt-con">
                                                昨日收入：{$yesterday_data.order_money}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="clear"></div>
                            </div>

                            <div class="overview-value">{$today_data.order_money}</div>
                            <div class="overview-rate">
                                <div>日同比 {$ratio_data.order_money}
                                    {if $ratio_data.order_money > 0}
                                    <img src="SHOP_IMG/shop-rate-add.png">
                                    {else /}
                                    <img src="SHOP_IMG/shop-rate-less.png">
                                    {/if}
                                </div>
                                <div>昨日订单新增 {$yesterday_data.order_money}</div>
                            </div>

                            <div class="overview-bottom">
                                <div class="overview-bottom-text">总收入</div>
                                <div class="overview-bottom-value">{$total_data.order_money}</div>
                                <div class="clear"></div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
		</div>

        <div class="admin-row data-statistics">
            <div class="admin-col-md4">
                <div class="ns-survey-detail-con echarts-wrap">
                    <div class="echarts-order">
                        <h5>店铺套餐订单</h5>
                        <div id="order" style="width: 100%; height: 400px;"></div>
                    </div>
                </div>
            </div>
            <div class="admin-col-md4">
                <div class="ns-survey-detail-con echarts-wrap">
                    <div class="echarts-money">
                        <h5>短信充值订单</h5>
                        <div id="money" style="width: 100%; height: 400px;"></div>
                    </div>
                </div>
            </div>

        </div>

        <div class="common-function">
            <blockquote class="layui-elem-quote">常用功能</blockquote>
			<div class="common-function-box layui-row">
			    <a class="layui-col-md2" href="{:url('admin/sysuser/add')}">
			        <div class="ns-index-img-box">
			            <img src="ADMIN_IMG/index/add_user.png">
			        </div>
			        <div class="ns-text-box">添加用户</div>
			    </a>
			    <a class="layui-col-md2" href="{:url('admin/sysuser/lists')}">
			        <div class="ns-index-img-box">
			            <img src="ADMIN_IMG/index/user_list.png">
			        </div>
			        <div class="ns-text-box">用户列表</div>
			    </a>
			    <a class="layui-col-md2" href="{:url('admin/upload/config')}">
			        <div class="ns-index-img-box">
			            <img src="ADMIN_IMG/index/upload_config.png">
			        </div>
			        <div class="ns-text-box">上传设置</div>
			    </a>
			    <a class="layui-col-md2" href="{:url('admin/config/pay')}">
			        <div class="ns-index-img-box">
			            <img src="ADMIN_IMG/index/pay_config.png">
			        </div>
			        <div class="ns-text-box">支付设置</div>
			    </a>
			    <a class="layui-col-md2" href="{:url('admin/message/sms')}">
			        <div class="ns-index-img-box">
			            <img src="ADMIN_IMG/index/sms_config.png">
			        </div>
			        <div class="ns-text-box">短信设置</div>
			    </a>
			</div>
        </div>

        <div class="other-info">
            <div class="layui-row layui-col-space10">
                <div class="layui-col-md12">
                    <blockquote class="layui-elem-quote">版本信息</blockquote>
                    <div class="versions-info-box">
                        <p><span>版本号：</span>{$sys_version_no}</p>
                        <p><span>版本名称：</span>{$sys_version_name}</p>
                        <p><span>版本类型：</span>{$sys_version}</p>
                        <p><span>版本编号：</span>{$sys_release}</p>
                        <p><span>官方网站：</span><a class="ns-text-color" href="https://www.niushop.com" target="_blank">官方网站</a></p>
                        <p><span>官方论坛：</span><a class="ns-text-color" href="https://bbs.niushop.com/forum.php" target="_blank">交流论坛</a></p>
                    </div>
                </div>
            </div>

            <div class="system-function">
                <blockquote class="layui-elem-quote">系统信息</blockquote>
                <table class="layui-table">
                    <colgroup>
                        <col width="20%">
                        <col width="30%">
                        <col width="20%">
                        <col width="30%">
                    </colgroup>
                    <tbody>
                    <tr>
                        <td class="ns-bg-color-light-gray">服务器操作系统</td>
                        <td>{$system_config['os']}</td>
                        <td class="ns-bg-color-light-gray">服务器域名</td>
                        <td>{$system_config['dns']}:{$system_config['port']}</td>
                    </tr>
                    <tr>
                        <td class="ns-bg-color-light-gray">服务器环境</td>
                        <td>{$system_config['server_software']}</td>
                        <td class="ns-bg-color-light-gray">PHP版本</td>
                        <td>{$system_config['php_version']}</td>
                    </tr>
                    <tr>
                        <td class="ns-bg-color-light-gray">文件上传限制</td>
                        <td>{$system_config['upload_max_filesize']}</td>
                        <td class="ns-bg-color-light-gray">GD版本</td>
                        <td>{$system_config['gd_version']}</td>
                    </tr>
                    <tr>
                        <td class="ns-bg-color-light-gray">sockets开启</td>
                        <td>{if condition="$system_config['sockets'] eq true"}已开启{else/}<span style="color:red;">未开启，邮箱功能将无法正常使用</span>{/if}</td>
                        <td class="ns-bg-color-light-gray">curl支持</td>
                        <td>{if condition="$system_config['curl'] eq true"}支持{else/}<span style="color:red;">不支持，微信和支付宝等功能将无法正常使用</span>{/if}</td>
                    </tr>
                    <tr>
                        <td class="ns-bg-color-light-gray">openssl开启</td>
                        <td>{if condition="$system_config['openssl'] eq true"}已开启{else/}<span style="color:red;">未开启，不支持https</span>{/if}</td>
                        <td class="ns-bg-color-light-gray">fileinfo开启</td>
                        <td>{if condition="$system_config['fileinfo'] eq true"}已开启{else/}<span style="color:red;">未开启，将无法获取上传文件类型，导致上传图片失败</span>{/if}</td>
                    </tr>
                    <tr>
                        <td class="ns-bg-color-light-gray">upload目录权限</td>
                        <td>{if $system_config['upload_dir_jurisdiction'] == 1}可读可写{else/}<span style="color:red;">不可读不可写，会造成图片无法上传和访问</span>{/if}</td>
                        <td class="ns-bg-color-light-gray">runtime目录权限</td>
                        <td>{if $system_config['runtime_dir_jurisdiction'] == 1}可读可写{else/}<span style="color:red;">不可读不可写，会造成编译文件缓存文件无法生成读取，是网站访问出错</span>{/if}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div class="index-info">
        <div class="layui-card ns-card-common">
            <div class="layui-card-header">
                <span class="">客户服务</span>
            </div>
            <div class="layui-card-body">
                <p class="ns-text-color-dark-gray">客服电话：400-886-7993</p>
                <p class="ns-text-color-dark-gray">官网：https://www.niushop.com/</p>
                <p class="ns-text-color-dark-gray">交流群：29507902</p>
            </div>
        </div>
        <div class="layui-card ns-card-common">
            <div class="layui-card-header">
                <span class="">最新动态</span>
            </div>
            <div class="layui-card-body news-list">

            </div>
        </div>
    </div>

</div>

{/block}
{block name="script"}
<script src="SHOP_JS/echarts.min.js"></script>
<script>
	var time = (new Date()).getTime();
	var date = ns.time_to_date(time / 1000);
	$(".ns-card-sub").text("更新时间：" + date);

	/* 版本更新 */
    $("body").on("click",".version-upgrade span",function () {
        $(this).parents(".version-upgrade").addClass("layui-hide");
    });

    news();
    //官网新闻

    function news(){
        $.ajax({
            url: "{:addon_url('admin/index/news')}",
            type: "POST",
            dataType: "JSON",
            success: function(res) {
                if(res.code < 0 || res.data.list.length == 0){
                    $(".news-list").append('<p class="ns-text-color-dark-gray"><span class="ns-bg-color">1</span>暂时没有官网资讯！</p>');
                }else{
                    $.each(res.data.list, function(key, value) {
                        var sort = key + 1;
                        $(".news-list").append('<p class="ns-text-color-dark-gray"><span class="ns-bg-color">'+sort+'</span><a href="'+ value.url +'" target="_blank" >'+value.title+'！</a></p>');
                    });
                }
            }
        });
    }


    $(function () {

        var ten_day_json = '';
        function getDay(day){
            var today = new Date();
            var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
            today.setTime(targetday_milliseconds); //注意，这行是关键代码
            var tYear = today.getFullYear();
            var tMonth = today.getMonth();
            var tDate = today.getDate();
            tMonth = doHandleMonth(tMonth + 1);
            tDate = doHandleMonth(tDate);
            return tMonth + "-" + tDate;
        }

        function doHandleMonth(month){
            var m = month;
            if(month.toString().length == 1){
                m = "0" + month;
            }
            return m;
        }

        var data = [getDay(-9), getDay(-8), getDay(-7), getDay(-6), getDay(-5), getDay(-4), getDay(-3), getDay(-2), getDay(-1), getDay(0)];
        var myChart = echarts.init(document.getElementById('order'));

        // 指定图表的配置项和数据
        option = {
            xAxis: {
                type: 'category',
                data: data
            },
            yAxis: {
                type: 'value'
            },
            tooltip: {
                formatter: function(params, ticket, callback) {
                    return "日期：" + data[params.dataIndex] + '<br />' + params.seriesName + "：" + params.value + "元";
                },
                backgroundColor: 'rgba(0, 0, 0, 0.5)',
                padding: [5, 10],
                textStyle: {
                    color: '#fff',
                    lineHeight: 30,
                }
            },
            series: [{
                name: ['店铺套餐订单'],
                data: '{$ten_day.site}'.split(','),
                type: 'bar',
                showBackground: true,
                barCategoryGap: '50%',
                itemStyle: {
                    color: new echarts.graphic.LinearGradient(
                        0, 0, 0, 1,
                        [
                            {offset: 0, color: '#7bb1fd'},
                            {offset: 1, color: '#4685fd'}
                        ]
                    )
                }
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);

        // 基于准备好的dom，初始化echarts实例
        var moneyChart = echarts.init(document.getElementById('money'));

        // 指定图表的配置项和数据
        moneyOption = {
            xAxis: {
                type: 'category',
                data: data
            },
            yAxis: {
                type: 'value'
            },
            tooltip: {
                trigger: 'axis',
                showContent: true,
                backgroundColor: 'rgba(0, 0, 0, 0.5)',
                padding: [5, 10],
                textStyle: {
                    color: '#fff',
                    lineHeight: 30,
                },
                formatter: function(params, ticket, callback) {
                    return "日期：" + params[0].axisValue + '<br />' + params[0].seriesName + "：" + params[0].value + "元";
                },
            },
            series: [{
                name: ['短信充值订单 '],
                data: '{$ten_day.sms}'.split(','),
                type: 'line',
                smooth: true,
                itemStyle: {
                    color: '#4685FD'
                }
            }]
        };

        // 使用刚指定的配置项和数据显示图表。
        moneyChart.setOption(moneyOption);
    });

</script>
{/block}
